package com.zork.cmdb.webapi.common.swagger;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author chenjh
 * @date 2018/5/14
 * @description
 */
@Configuration
@EnableSwagger2
public class Swagger2Config {


    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com.zork.cmdb.webapi.api"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("cmdb数据接口API说明文档")
                .description("cmdb数据接口API说明文档")
                .termsOfServiceUrl("http://zorkdata.com.cn/index.php?c=category&id=40")
                .contact(new Contact("cmdb团队", "http://zorkdata.com.cn/index.php?c=category&id=40", "xingguohua@zork.com.cn"))
                .version("1.0.0")
                .build();
    }
}